{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "6a0edd68",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['jianglaoban', 34567, 23]\n",
      "[['liliumang', 12345, 20], ['siwen', 23455, 20], ['jianglaoban', 34567, 23]]\n",
      "[['liliumang', 12345, 20], ['siwen', 23455, 20], ['jianglaoban', 34567, 23]]\n",
      "['jianglaoban', 34567, 23]\n",
      "[['siwen', 23455, 20], ['jianglaoban', 34567, 23]]\n",
      "[]\n",
      "[['siwen', 23455, 20], ['jianglaoban', 34567, 23], ['kaijun', 3456, 12]]\n",
      "[['liliumang', 12345, 20], ['siwen', 23455, 20], ['jianglaoban', 34567, 23], ['kaijun', 3456, 12]]\n",
      "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n",
      "[0, 2, 4]\n"
     ]
    }
   ],
   "source": [
    "# Author:Junbin-guo\n",
    "# date:2021.9.31\n",
    "# week05\n",
    "# 数据结构之列表\n",
    "# 主要知识：列表入门\n",
    "\n",
    "# user_data = \"zhichao||gaojin||linzhiliang\"\n",
    "# print(user_data[1])\n",
    "# 取起来相当麻烦\n",
    "# 引入列表\n",
    "# 列表是有顺序的\n",
    "\n",
    "\n",
    "user_daye_list =[\"liumang\",\"siwen\",\"jianglaoban\",\"kaijun\"]\n",
    "password_list = [12345,23455,34567]\n",
    "age_list = [23,23,23,23]\n",
    "\n",
    "# 列表的嵌套\n",
    "user_daye_list =[[\"liliumang\",12345,20],[\"siwen\",23455,20],[\"jianglaoban\",34567,23],[\"kaijun\",3456,12]]\n",
    "\n",
    "\n",
    "# 1.从左往右取值 (index & slice)\n",
    "print(user_daye_list[2])\n",
    "# 总结切片slice.右边的值取不到，例如[0:3],取不到3这个值：\n",
    "print(user_daye_list[0:3])\n",
    "# 当从0开始时，0可以忽略不写\n",
    "print(user_daye_list[:3])\n",
    "# -3，-2，-1，0，1，2，3，4...\n",
    "# 2.从右往左取值(index & slice)\n",
    "print(user_daye_list[-2])\n",
    "# 切片slice,右边的值取不到\n",
    "print(user_daye_list[-3:-1])\n",
    "\n",
    "# 如何去到最后一个值\n",
    "# 第一种情况\n",
    "print(user_daye_list[-3:0])\n",
    "# 情况是取值为空，故上述不成立\n",
    "\n",
    "# 从右往左要取到最后一个值，不能写0，直接省略不屑\n",
    "print(user_daye_list[-3:])\n",
    "\n",
    "# 是否能全部省略不写\n",
    "print(user_daye_list[:])\n",
    "\n",
    "# 步长.list列表slice : [start:stop:step]\n",
    "'''\n",
    "如果没有指定的开始值，则默认为0；\n",
    "如果没有指定的结束值，则取列表的最大值；\n",
    "如果没有指定的步长值，则默认步长为1.\n",
    "'''\n",
    "\n",
    "num = list(range(10))\n",
    "print(num)\n",
    "print(num[0:6:2])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "287302ab",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
